<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="姓名" prop="staffName">
        <el-input
          v-model="queryParams.staffName"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号码" prop="telephone">
        <el-input
          v-model="queryParams.telephone"
          placeholder="请输入手机号码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工资所属月份" prop="salaryMonth">
        <el-date-picker clearable
          v-model="queryParams.salaryMonth"
          type="date"
          format="yyyy-MM"
          value-format="yyyy-MM"
          placeholder="请选择工资所属月份">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="salaryList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="姓名" align="center" prop="staffName" />
      <el-table-column label="部门名称" align="center" prop="deptName" />
      <el-table-column label="基本工资" align="center" prop="basePay" />
      <el-table-column label="绩效" align="center" prop="achievement" />
      <el-table-column label="薪资应发合计" align="center" prop="totalSalary" />
      <el-table-column label="事假" align="center" prop="compassionateLeave" />
      <el-table-column label="病假" align="center" prop="sickLeave" />
      <el-table-column label="缺勤" align="center" prop="absence" />
      <el-table-column label="迟到早退" align="center" prop="late" />
      <el-table-column label="缺卡" align="center" prop="cardShortage" />
      <el-table-column label="扣款小计" align="center" prop="totalDeduction" />
      <el-table-column label="补贴/加班" align="center" prop="subsidy" />
      <el-table-column label="满勤奖" align="center" prop="fullAttendance" />
      <el-table-column label="工龄工资" align="center" prop="seniorityPay" />
      <el-table-column label="变动工资小计" align="center" prop="totalChange" />
      <el-table-column label="租赁提成" align="center" prop="leaseCommission" />
      <el-table-column label="销售提成" align="center" prop="salesCommission" />
      <el-table-column label="管理提成" align="center" prop="managementCommission" />
      <el-table-column label="技术提成" align="center" prop="technicalCommission" />
      <el-table-column label="其他提成" align="center" prop="otherCommission" />
      <el-table-column label="提成小计" align="center" prop="totalCommission" />
      <el-table-column label="扣除" align="center" prop="deduction" />
      <el-table-column label="个人养老保险" align="center" prop="personalEndowmentInsurance" />
      <el-table-column label="个人社保小计" align="center" prop="personalTotalInsurance" />
      <el-table-column label="个人医疗保险" align="center" prop="personalMedicalInsurance" />
      <el-table-column label="个人失业保险" align="center" prop="personalUnemploymentInsurance" />
      <el-table-column label="单位养老保险" align="center" prop="companyEndowmentInsurance" />
      <el-table-column label="单位医疗保险" align="center" prop="companyMedicalInsurance" />
      <el-table-column label="单位工伤保险" align="center" prop="companyIndustrialInjuryInsurance" />
      <el-table-column label="单位失业保险" align="center" prop="companyUnemploymentInsurance" />
      <el-table-column label="单位社保小计" align="center" prop="companyTotalInsurance" />
      <el-table-column label="个人所得税" align="center" prop="individualIncomeTax" />
      <el-table-column label="其他扣除" align="center" prop="otherDeductions" />
      <el-table-column label="实发工资" align="center" prop="netSalary" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="人工成本" align="center" prop="laborCost" />
      <el-table-column label="创建者id" align="center" prop="createId" />
      <el-table-column label="状态" align="center" prop="status" />
      <el-table-column label="工资所属月份" align="center" prop="salaryMonth" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.salaryMonth, '{y}-{m}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="身份证号" align="center" prop="idCardNumber" />
      <el-table-column label="手机号码" align="center" prop="telephone" />
      <el-table-column label="开户行" align="center" prop="bank" />
      <el-table-column label="银行卡号" align="center" prop="bankCardNo" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改薪资对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="工资所属月份" prop="salaryMonth">
          <el-date-picker clearable
                          v-model="form.salaryMonth"
                          type="date"
                          format="yyyy-MM"
                          placeholder="请选择工资所属月份">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="姓名" prop="staffName">
          <el-input v-model="form.staffName" readonly placeholder="">
            <template slot="append">
              <el-button type="primary" style="width: 120px" @click="openImportUser">
                选择员工
              </el-button>
            </template>
          </el-input>
        </el-form-item>
<!--        <el-form-item label="员工id" prop="staffId">
          <el-input v-model="form.staffId" placeholder="请输入员工id" />
        </el-form-item>-->
        <el-form-item label="身份证号" prop="idCardNumber">
          <el-input v-model="form.idCardNumber" readonly placeholder="请输入身份证号" />
        </el-form-item>
        <el-form-item label="手机号码" prop="telephone">
          <el-input v-model="form.telephone" readonly placeholder="请输入手机号码" />
        </el-form-item>
        <el-form-item label="开户行" prop="bank">
          <el-input v-model="form.bank" readonly placeholder="请输入开户行" />
        </el-form-item>
        <el-form-item label="银行卡号" prop="bankCardNo">
          <el-input v-model="form.bankCardNo" readonly placeholder="请输入银行卡号" />
        </el-form-item>
<!--        <el-form-item label="部门id" prop="deptId">
          <el-input v-model="form.deptId" placeholder="请输入部门id" />
        </el-form-item>-->
        <el-form-item label="部门名称" prop="deptName">
          <el-input v-model="form.deptName" readonly placeholder="请输入部门名称" />
        </el-form-item>
        <el-form-item label="基本工资" prop="basePay">
          <el-input v-model="form.basePay" placeholder="请输入基本工资" @blur="setTotalSalary()" />
        </el-form-item>
        <el-form-item label="绩效" prop="achievement">
          <el-input v-model="form.achievement" placeholder="请输入绩效" @blur="setTotalSalary()" />
        </el-form-item>
        <el-form-item label="薪资应发合计" prop="totalSalary">
          <el-input v-model="form.totalSalary" readonly placeholder="" />
        </el-form-item>
        <el-form-item label="事假" prop="compassionateLeave">
          <el-input v-model="form.compassionateLeave" placeholder="请输入事假"  @blur="setTotalDeduction()"  />
        </el-form-item>
        <el-form-item label="病假" prop="sickLeave">
          <el-input v-model="form.sickLeave" placeholder="请输入病假"  @blur="setTotalDeduction()"  />
        </el-form-item>
        <el-form-item label="缺勤" prop="absence">
          <el-input v-model="form.absence" placeholder="请输入缺勤"  @blur="setTotalDeduction()" />
        </el-form-item>
        <el-form-item label="迟到早退" prop="late">
          <el-input v-model="form.late" placeholder="请输入迟到早退" @blur="setTotalDeduction()" />
        </el-form-item>
        <el-form-item label="缺卡" prop="cardShortage">
          <el-input v-model="form.cardShortage" placeholder="请输入缺卡" @blur="setTotalDeduction()"/>
        </el-form-item>
        <el-form-item label="扣款小计" prop="totalDeduction">
          <el-input v-model="form.totalDeduction" readonly placeholder="" />
        </el-form-item>
        <el-form-item label="补贴/加班" prop="subsidy">
          <el-input v-model="form.subsidy" placeholder="请输入补贴/加班"  @blur="setTotalChange()"/>
        </el-form-item>
        <el-form-item label="满勤奖" prop="fullAttendance">
          <el-input v-model="form.fullAttendance" placeholder="请输入满勤奖"  @blur="setTotalChange()"/>
        </el-form-item>
        <el-form-item label="工龄工资" prop="seniorityPay">
          <el-input v-model="form.seniorityPay" placeholder="请输入工龄工资" @blur="setTotalChange()" />
        </el-form-item>
        <el-form-item label="变动工资小计" prop="totalChange">
          <el-input v-model="form.totalChange" readonly placeholder="请输入变动工资小计" />
        </el-form-item>
        <el-form-item label="租赁提成" prop="leaseCommission">
          <el-input v-model="form.leaseCommission" placeholder="请输入租赁提成" @blur="setTotalCommission()" />
        </el-form-item>
        <el-form-item label="销售提成" prop="salesCommission">
          <el-input v-model="form.salesCommission" placeholder="请输入销售提成"  @blur="setTotalCommission()" />
        </el-form-item>
        <el-form-item label="管理提成" prop="managementCommission">
          <el-input v-model="form.managementCommission" placeholder="请输入管理提成"  @blur="setTotalCommission()" />
        </el-form-item>
        <el-form-item label="技术提成" prop="technicalCommission">
          <el-input v-model="form.technicalCommission" placeholder="请输入技术提成"  @blur="setTotalCommission()" />
        </el-form-item>
        <el-form-item label="其他提成" prop="otherCommission">
          <el-input v-model="form.otherCommission" placeholder="请输入其他提成"  @blur="setTotalCommission()"  />
        </el-form-item>
        <el-form-item label="提成小计" prop="totalCommission">
          <el-input v-model="form.totalCommission" readonly placeholder="请输入提成小计" />
        </el-form-item>
        <el-form-item label="扣除" prop="deduction">
          <el-input v-model="form.deduction" placeholder="请输入扣除" @blur="setNetSalary()"/>
        </el-form-item>
        <el-form-item label="个人养老保险" prop="personalEndowmentInsurance">
          <el-input v-model="form.personalEndowmentInsurance" placeholder="请输入个人养老保险"  @blur="setPersonalTotalInsurance()"/>
        </el-form-item>

        <el-form-item label="个人医疗保险" prop="personalMedicalInsurance">
          <el-input v-model="form.personalMedicalInsurance" placeholder="请输入个人医疗保险" @blur="setPersonalTotalInsurance()" />
        </el-form-item>
        <el-form-item label="个人失业保险" prop="personalUnemploymentInsurance">
          <el-input v-model="form.personalUnemploymentInsurance" placeholder="请输入个人失业保险" @blur="setPersonalTotalInsurance()" />
        </el-form-item>
        <el-form-item label="个人社保小计" prop="personalTotalInsurance">
          <el-input v-model="form.personalTotalInsurance" readonly placeholder="" />
        </el-form-item>
        <el-form-item label="单位养老保险" prop="companyEndowmentInsurance">
          <el-input v-model="form.companyEndowmentInsurance" placeholder="请输入单位养老保险"  @blur="setCompanyTotalInsurance()" />
        </el-form-item>
        <el-form-item label="单位医疗保险" prop="companyMedicalInsurance">
          <el-input v-model="form.companyMedicalInsurance" placeholder="请输入单位医疗保险" @blur="setCompanyTotalInsurance()"  />
        </el-form-item>
        <el-form-item label="单位工伤保险" prop="companyIndustrialInjuryInsurance">
          <el-input v-model="form.companyIndustrialInjuryInsurance" placeholder="请输入单位工伤保险" @blur="setCompanyTotalInsurance()"  />
        </el-form-item>
        <el-form-item label="单位失业保险" prop="companyUnemploymentInsurance">
          <el-input v-model="form.companyUnemploymentInsurance" placeholder="请输入单位失业保险" @blur="setCompanyTotalInsurance()" />
        </el-form-item>
        <el-form-item label="单位社保小计" prop="companyTotalInsurance">
          <el-input v-model="form.companyTotalInsurance" readonly placeholder="" />
        </el-form-item>
        <el-form-item label="个人所得税" prop="individualIncomeTax">
          <el-input v-model="form.individualIncomeTax" placeholder="请输入个人所得税" @blur="setNetSalary()"/>
        </el-form-item>
        <el-form-item label="其他扣除" prop="otherDeductions">
          <el-input v-model="form.otherDeductions" placeholder="请输入其他扣除" @blur="setNetSalary()" />
        </el-form-item>
        <el-form-item label="实发工资" prop="netSalary">
          <el-input v-model="form.netSalary" placeholder="请输入实发工资" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="人工成本" prop="laborCost">
          <el-input v-model="form.laborCost" placeholder="请输入人工成本" />
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <import-staff ref="import" @showStaff="showStaff"></import-staff>
  </div>
</template>

<script>
import { listSalary, getSalary, delSalary, addSalary, updateSalary } from "@/api/module/salary";
import importStaff from "./staff";

export default {
  name: "Salary",
  components:{importStaff},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 薪资表格数据
      salaryList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        staffName: null,
        staffId: null,
        idCardNumber: null,
        telephone: null,
        bank: null,
        bankCardNo: null,
        deptId: null,
        deptName: null,
        basePay: null,
        achievement: null,
        totalSalary: null,
        compassionateLeave: null,
        sickLeave: null,
        absence: null,
        late: null,
        cardShortage: null,
        totalDeduction: null,
        subsidy: null,
        fullAttendance: null,
        seniorityPay: null,
        totalChange: null,
        leaseCommission: null,
        salesCommission: null,
        managementCommission: null,
        technicalCommission: null,
        otherCommission: null,
        totalCommission: null,
        deduction: null,
        personalEndowmentInsurance: null,
        personalTotalInsurance: null,
        personalMedicalInsurance: null,
        personalUnemploymentInsurance: null,
        companyEndowmentInsurance: null,
        companyMedicalInsurance: null,
        companyIndustrialInjuryInsurance: null,
        companyUnemploymentInsurance: null,
        companyTotalInsurance: null,
        individualIncomeTax: null,
        otherDeductions: null,
        netSalary: null,
        laborCost: null,
        createId: null,
        status: null,
        salaryMonth: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
    this.getSalaryMonth();
  },
  methods: {

    /** 打开员工弹窗 */
    openImportUser() {
      this.$refs.import.show();
    },
    showStaff(data){
      //负责人
      this.form.staffId=data.userId;
      this.form.staffName=data.userName;
      this.form.idCardNumber=data.card;
      this.form.telephone=data.tel;
      this.form.bank=data.bank;
      this.form.bankCardNo=data.bankCardNo;
      this.form.deptId=data.deptId;
      this.form.deptName=data.deptName;
      this.form.basePay=data.basePay;
    },
    /** 查询薪资列表 */
    getList() {
      this.loading = true;
      listSalary(this.queryParams).then(response => {
        this.salaryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        staffName: null,
        staffId: null,
        idCardNumber: null,
        telephone: null,
        bank: null,
        bankCardNo: null,
        deptId: null,
        deptName: null,
        basePay: null,
        achievement: null,
        totalSalary: null,
        compassionateLeave: null,
        sickLeave: null,
        absence: null,
        late: null,
        cardShortage: null,
        totalDeduction: null,
        subsidy: null,
        fullAttendance: null,
        seniorityPay: null,
        totalChange: null,
        leaseCommission: null,
        salesCommission: null,
        managementCommission: null,
        technicalCommission: null,
        otherCommission: null,
        totalCommission: null,
        deduction: null,
        personalEndowmentInsurance: null,
        personalTotalInsurance: null,
        personalMedicalInsurance: null,
        personalUnemploymentInsurance: null,
        companyEndowmentInsurance: null,
        companyMedicalInsurance: null,
        companyIndustrialInjuryInsurance: null,
        companyUnemploymentInsurance: null,
        companyTotalInsurance: null,
        individualIncomeTax: null,
        otherDeductions: null,
        netSalary: null,
        remark: null,
        laborCost: null,
        createBy: null,
        updateBy: null,
        updateTime: null,
        createId: null,
        createTime: null,
        status: "0",
        delFlag: null,
        salaryMonth: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加薪资";
      this.form.salaryMonth=this.getSalaryMonth();
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getSalary(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改薪资";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateSalary(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addSalary(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除薪资编号为"' + ids + '"的数据项？').then(function() {
        return delSalary(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('module/salary/export', {
        ...this.queryParams
      }, `salary_${new Date().getTime()}.xlsx`)
    },
    getSalaryMonth (){
      var date = new Date();
      var year = date.getFullYear();        //年 ,从 Date 对象以四位数字返回年份
      var month = date.getMonth() + 1;              //获取当前日期的月

      var year2 = year;
      var month2 = parseInt(month)-1;
      if(month2==0) {
        year2 = parseInt(year2)-1;
        month2 = 12;
      }
      if(month2<10) {
        month2 = '0'+month2;
      }
      var m = year2.toString();
      var n= month2.toString();
      var t2 = m+"-"+n;
      console.log(t2)
      return t2;
    },
    setTotalSalary(){
      var total = 0;
      if(this.form.basePay){
        total = total + parseFloat(this.form.basePay);
      }
      if(this.form.achievement){
        total = total + parseFloat(this.form.achievement);
      }
      this.form.totalSalary = total;
      this.setNetSalary();
    },
    setTotalDeduction(){
      var total = 0;
      if(this.form.compassionateLeave){
        total = total + parseFloat(this.form.compassionateLeave);
      }
      if(this.form.sickLeave){
        total = total + parseFloat(this.form.sickLeave);
      }
      if(this.form.absence){
        total = total + parseFloat(this.form.absence);
      }
      if(this.form.late){
        total = total + parseFloat(this.form.late);
      }
      if(this.form.cardShortage){
        total = total + parseFloat(this.form.cardShortage);
      }
      this.form.totalDeduction = total;
      this.setNetSalary();
    },
    setTotalChange(){
      var total = 0;
      if(this.form.subsidy){
        total = total + parseFloat(this.form.subsidy);
      }
      if(this.form.fullAttendance){
        total = total + parseFloat(this.form.fullAttendance);
      }
      if(this.form.seniorityPay){
        total = total + parseFloat(this.form.seniorityPay);
      }
      this.form.totalChange = total;
      this.setNetSalary();
    },
    setTotalCommission(){
      var total = 0;
      if(this.form.leaseCommission){
        total = total + parseFloat(this.form.leaseCommission);
      }
      if(this.form.salesCommission){
        total = total + parseFloat(this.form.salesCommission);
      }
      if(this.form.managementCommission){
        total = total + parseFloat(this.form.managementCommission);
      }
      if(this.form.technicalCommission){
        total = total + parseFloat(this.form.technicalCommission);
      }
      if(this.form.otherCommission){
        total = total + parseFloat(this.form.otherCommission);
      }
      this.form.totalCommission = total;
      this.setNetSalary();
    },
    setPersonalTotalInsurance(){
      var total = 0;
      if(this.form.personalEndowmentInsurance){
        total = total + parseFloat(this.form.personalEndowmentInsurance);
      }
      if(this.form.personalMedicalInsurance){
        total = total + parseFloat(this.form.personalMedicalInsurance);
      }
      if(this.form.personalUnemploymentInsurance){
        total = total + parseFloat(this.form.personalUnemploymentInsurance);
      }

      this.form.personalTotalInsurance = total;
      this.setNetSalary();
    },
    setCompanyTotalInsurance(){
      var total = 0;
      if(this.form.companyEndowmentInsurance){
        total = total + parseFloat(this.form.companyEndowmentInsurance);
      }
      if(this.form.companyMedicalInsurance){
        total = total + parseFloat(this.form.companyMedicalInsurance);
      }
      if(this.form.companyIndustrialInjuryInsurance){
        total = total + parseFloat(this.form.companyIndustrialInjuryInsurance);
      }
      if(this.form.companyUnemploymentInsurance){
        total = total + parseFloat(this.form.companyUnemploymentInsurance);
      }
      this.form.companyTotalInsurance = total;
      this.setNetSalary();
    },
    setNetSalary(){
      var total = 0;
      if(this.form.totalSalary){
        total = total + parseFloat(this.form.totalSalary);
      }
      if(this.form.totalDeduction){
        total = total - parseFloat(this.form.totalDeduction);
      }
      if(this.form.totalChange){
        total = total + parseFloat(this.form.totalChange);
      }
      if(this.form.totalCommission){
        total = total + parseFloat(this.form.totalCommission);
      }
      if(this.form.deduction){
        total = total - parseFloat(this.form.deduction);
      }
      if(this.form.personalTotalInsurance){
        total = total - parseFloat(this.form.personalTotalInsurance);
      }
      if(this.form.individualIncomeTax){
        total = total - parseFloat(this.form.individualIncomeTax);
      }
      if(this.form.otherDeductions){
        total = total - parseFloat(this.form.otherDeductions);
      }
      this.form.netSalary = total;
      //人工成本
      this.setLaborCost();
    },
    setLaborCost(){
      var total = 0;
      if(this.form.netSalary){
        total = total + parseFloat(this.form.netSalary);
      }
      if(this.form.companyTotalInsurance){
        total = total + parseFloat(this.form.companyTotalInsurance);
      }
      this.form.laborCost = total;
    }
  }
};
</script>
